package com.project.demo.service;

import com.project.demo.dao.UserMapper;
import com.project.demo.entity.SysKey;
import com.project.demo.entity.User;
import com.project.demo.parameter.SystemKey;
import com.project.demo.service.base.BaseService;
import com.project.demo.util.SysKeyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 用户账户：用于保存用户登录信息(User)表服务接口
 *
 */
@Service
public class UserService extends BaseService<User> implements ApplicationRunner {

    public static Map<String,SysKey> map = new HashMap();

    @Autowired
    private UserMapper userMapper;

    public String getSysKey() {
        if(StringUtils.isEmpty(SysKeyUtil.getPublicKey())){
            SysKeyUtil.getSysKey();
        }
        String publicKey = SysKeyUtil.getPublicKey();
        return publicKey;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
//        SysKeyUtil.getSysKey();
        if(StringUtils.isEmpty(SysKeyUtil.getPublicKey())){
            SysKeyUtil.getSysKey();
        }
        String publicKey = SysKeyUtil.getPublicKey();
    }
}


